package com.ruoyi.appService.CollegeStudentsTestList.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.appService.CollegeStudentsTestList.domain.ZMentalHealthTestList;
import com.ruoyi.appService.CollegeStudentsTestList.service.IZMentalHealthTestListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大学生心理健康测试列表Controller
 * 
 * @author ç¹è½æ²
 * @date 2025-05-16
 */
@RestController
@RequestMapping("/CollegeStudents/CollegeStudentsTestList")
public class ZMentalHealthTestListController extends BaseController
{
    @Autowired
    private IZMentalHealthTestListService zMentalHealthTestListService;

    /**
     * 查询大学生心理健康测试列表列表
     */
    @PreAuthorize("@ss.hasPermi('CollegeStudents:CollegeStudentsTestList:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZMentalHealthTestList zMentalHealthTestList)
    {
        startPage();
        List<ZMentalHealthTestList> list = zMentalHealthTestListService.selectZMentalHealthTestListList(zMentalHealthTestList);
        return getDataTable(list);
    }

    @GetMapping("/listAll")
    public TableDataInfo listAll(ZMentalHealthTestList zMentalHealthTestList)
    {
        List<ZMentalHealthTestList> list = zMentalHealthTestListService.selectZMentalHealthTestListList(zMentalHealthTestList);
        return getDataTable(list);
    }


    /**
     * 导出大学生心理健康测试列表列表
     */
    @PreAuthorize("@ss.hasPermi('CollegeStudents:CollegeStudentsTestList:export')")
    @Log(title = "大学生心理健康测试列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZMentalHealthTestList zMentalHealthTestList)
    {
        List<ZMentalHealthTestList> list = zMentalHealthTestListService.selectZMentalHealthTestListList(zMentalHealthTestList);
        ExcelUtil<ZMentalHealthTestList> util = new ExcelUtil<ZMentalHealthTestList>(ZMentalHealthTestList.class);
        util.exportExcel(response, list, "大学生心理健康测试列表数据");
    }

    /**
     * 获取大学生心理健康测试列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('CollegeStudents:CollegeStudentsTestList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zMentalHealthTestListService.selectZMentalHealthTestListById(id));
    }

    /**
     * 新增大学生心理健康测试列表
     */
    @PreAuthorize("@ss.hasPermi('CollegeStudents:CollegeStudentsTestList:add')")
    @Log(title = "大学生心理健康测试列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZMentalHealthTestList zMentalHealthTestList)
    {
        return toAjax(zMentalHealthTestListService.insertZMentalHealthTestList(zMentalHealthTestList));
    }

    /**
     * 修改大学生心理健康测试列表
     */
    @PreAuthorize("@ss.hasPermi('CollegeStudents:CollegeStudentsTestList:edit')")
    @Log(title = "大学生心理健康测试列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZMentalHealthTestList zMentalHealthTestList)
    {
        return toAjax(zMentalHealthTestListService.updateZMentalHealthTestList(zMentalHealthTestList));
    }

    /**
     * 删除大学生心理健康测试列表
     */
    @PreAuthorize("@ss.hasPermi('CollegeStudents:CollegeStudentsTestList:remove')")
    @Log(title = "大学生心理健康测试列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zMentalHealthTestListService.deleteZMentalHealthTestListByIds(ids));
    }


    //    根据用户id查询所有已经完成的测试
    @GetMapping("/completedTest")
    public AjaxResult  selectAllCompentedTest   (HttpServletRequest request)
    {
        return success(zMentalHealthTestListService.selectCompletedTestList(request) );
    }


    //新增已完成的测试
    @GetMapping("/insertCompletedTest/{id}")
    public AjaxResult  insertCompentedTest   (@PathVariable int id,HttpServletRequest request)
    {
        zMentalHealthTestListService.insertCompletedTestList(id,request);
        return success( );
    }

}
